-
Notifications
You must be signed in to change notification settings - Fork 735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net: add TcpSocket::{set, get}_keepalive
#1385
Conversation
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
baed87c
to
04cd34f
Compare
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
13cdfe0
to
20a018c
Compare
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
i asked a friend who works at microsoft and she said to try this. the docs don't mention it anywhere, though, so who knows what will happen! Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Okay, I've updated this branch to use a builder-style API to workaround the issues with winsock, which I've described in the PR description. Let me know what you think! |
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two small things, but LGTM.
This might be the nicest, full-featured TCP keepalive API I've seen, well done.
src/net/tcp/socket.rs
Outdated
/// will start sending keepalive messages on an idle connection. | ||
/// | ||
/// Additionally, this will enable TCP keepalive on this socket, if it is | ||
/// not already enabled. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a # Notes
section saying that all parameters related to keepalive will be overwritten.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, that's actually only the case on Windows; on Unix, we can avoid overwriting previously set parameters. Do you think we should have the same behavior on Unix OSes even though it's less than ideal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's change it to that it might overwrite other keepalive parameters and that either only a single call should be made, or that all desired parameters should be set in all calls. I don't want to make unnecessary system calls on Unix.
Thanks! :) I noticed that |
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
cfb1ed7
to
605d07a
Compare
Thanks @hawkw. |
Originally implemented by @hawkw here in tokio-rs/mio#1385. Closed rust-lang#79. Fixes rust-lang#24.
Originally implemented by @hawkw here in tokio-rs/mio#1385. Closed #79. Fixes #24.
This commit adds methods to
TcpSocket
to enable/disable TCP keepalive,and set the keepalive idle time, probe interval, and retries, when the
OS supports configuring those values.
Because of how TCP keepalive is configured in Winsock, it's necessary to
use a builder-type API: the interval and idle time are set together as
separate fields on a struct, and if either is not set, it clobbers the
previous value. This means we can't just call that API twice, once with
each value set. Unlike Unix OSes, Windows also doesn't provide any way
to access the current value of these parameters, so we can't just
populate the other fields on the struct with the previous values, either
(incidentally, this also means we can't provide getters on Windows).
Signed-off-by: Eliza Weisman [email protected]